Botframework TypeError:无法在已被撤销的代理上执行"获取"

您所在的位置:网站首页 bot 代理 Botframework TypeError:无法在已被撤销的代理上执行"获取"

Botframework TypeError:无法在已被撤销的代理上执行"获取"

#Botframework TypeError:无法在已被撤销的代理上执行"获取"| 来源: 网络整理| 查看: 265

问题描述

我正在尝试开发一个将内容发送给学生模块(单位)的MS团队机器人.我创建了3个类:

methods.js =包含发送文本,附件等的所有方法 teambot.js =捕获用户的特定关键字,并基于执行功能. test.js =将机器人与airtable连接并相应地发送内容

我面对Cannot perform 'get' on a proxy that has been revoked错误.我认为这可能是因为上下文.我将上下文作为一个参数,我认为这可能不是正确的方法,我如何实现结果,并保留文件之间的上下文.

Teamsbot.js

const test = require("./test"); class TeamsBot extends TeamsActivityHandler { constructor() { super(); // record the likeCount this.likeCountObj = { likeCount: 0 }; this.onMessage(async (context, next) => { console.log("Running with Message Activity."); let txt = context.activity.text; // const removedMentionText = TurnContext.removeRecipientMention(context.activity); // if (removedMentionText) { // // Remove the line break // txt = removedMentionText.toLowerCase().replace(/\n|\r/g, "").trim(); // } // Trigger command by IM text switch (txt) { case "Begin": { await test.sendModuleContent(context) } // By calling next() you ensure that the next BotHandler is run. await next(); }); // Listen to MembersAdded event, view https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bots-notifications for more events this.onMembersAdded(async (context, next) => { const membersAdded = context.activity.membersAdded; for (let cnt = 0; cnt < membersAdded.length; cnt++) { if (membersAdded[cnt].id) { const card = cardTools.AdaptiveCards.declareWithoutData(rawWelcomeCard).render(); await context.sendActivity({ attachments: [CardFactory.adaptiveCard(card)] }); break; } } await next(); }); }

test.js

const ms = require('./methods') async function sendModuleContent(context) { data = module_text //fetched from Airtable await ms.sendText(context, data) }

methods.js

const {TeamsActivityHandler, ActivityHandler, MessageFactory } = require('botbuilder'); async function sendText(context, text){ console.log("Sending text") await context.sendActivity(text); } 推荐答案

请参考以下信息: typeerror :无法在被撤销的代理上执行

对test.js

进行以下更改 const { TurnContext } = require("botbuilder"); var conversationReferences = {}; var adapter; async function sendModuleContent(context) { data = module_text //fetched from Airtable const currentUser = context.activity.from.id; conversationReferences[currentUser] = TurnContext.getConversationReference(context.activity); adapter = context.adapter; await adapter.continueConversation(conversationReferences[currentUser], async turnContext => { await turnContext.sendActivity(data); }); }

本文地址:https://www.itbaoku.cn/post/2577025.html



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3